<include file="Public:header" />
<include file="Public:logo" />
<include file="Public:menu" />
<include file="Public:table_br" />
<load file="__ROOT__/images/js/datepick/jquery.datepick.css" />
<load file="__ROOT__/images/js/datepick/jquery.datepick.js" />
<load file="__ROOT__/images/js/datepick/jquery.datepick-zh-CN.js" />
<script>
    $(function(){
        $('#gg_title').focus();



        $('#save_gg').click(function(){   //相应保存公告按钮事件
            var gg_title=$('#gg_title').val();
            var gg_date=$('#gg_date').val();
            var gg_body=$('#gg_body').text();
            if(check(gg_title,gg_date,gg_body)){
                $.post("{:U('manger/save_gonggao')}",
                    {'gg_title':gg_title,
                     'gg_date':gg_date,
                     'gg_body':gg_body
                    },
                    function(data){chuli(data.status);},'json')
            }
        });

        function check(gg_title,gg_date,gg_body){
            if(gg_title=='' || gg_date=='' || gg_body==''){
                $('#pop').html('<font color="red">公告标题，公告日期，公告内容必须全部填写！</font>');
                $('#gg_title').focus();
                return false;
            }
            return true;
        }

        function chuli(data){
            switch(data){
                case 0:
                    $('#pop').html('<font color="red">公告标题，公告日期，公告内容必须全部填写！</font>');
                    $('#gg_title').focus();
                    break;
                case 1:
                    $('#pop').html('<font color="red">公告日期格式不正确！请正确填写公告日期格式！</font>');
                    $('#gg_date').val('');
                    $('#gg_date').focus();
                    break;
                case 2:
                    $('#pop').html('<font color="red">新公告添加成功！</font>');
                    $('#gg_title').val('');
                    $('#gg_date').val('');
                    $('#gg_body').text('');
                    $('#gg_title').focus();
                    break;
            }
        }


        $(document).ready(function(){
            $('#gg_date').datepick({dateFormat: 'yy-mm-dd'});
        });
    });
</script>
<tbody><center>
<table width="780" border="1" cellpadding="0" cellspacing="0" align="center" style="border-collapse:collapse" bordercolor="#000000">
<tr>
    <td width="15%" align="center" valign="top">
        <br>
        <include file="Manger:admin_menu" />
    </td>
    <td width="85%" valign="top">
        <a href="{:U('manger/index')}">管理首页</a>-公告管理
        <br><br>
        <b>添加公告：</b>
        <br>
        <a id="pop"></a><br>
        公告标题：<input type="text" id="gg_title" name="gg_title" value="" size="20" maxlength="50"/><br>
        公告日期：<input type="text" id="gg_date" name="gg_date" value="" size="20" readonly /><br>
        公告内容：<br>
        <textarea name="gg_body" id="gg_body" rows="4" cols="40"></textarea>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" value="添加公告" id="save_gg" />
    </td>
</tr>
</table>
</center></tbody>



<include file="Public:ender" />
